﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CarForm.aspx.cs" Inherits="FantastPlatform.Community.UI.InfoCollection.CarForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var car = new FantastPlatform.UI.AddCarGrid({
            renderTo: 'car_div',
            Id: '<%=GetId() %>',
            gridType: '<%=GetGridType() %>',
            btnEnable:'<%=GetbtnEnable() %>',
            CreatePoliceCode: '<%=GetCreatePoliceCode() %>',
            url: '../Service/PersonService.aspx?Action=GetCarsByPerson',
            height: 280,
            tbar: [{
                text: '添加',
                iconCls: 'add',
                id: 'addCarDetail',
                handler: carCellRecoder
            }
                , '-', {
                    text: '移除',
                    iconCls: 'delete',
                    id: 'deleteCarDetail',
                    handler: function () {
                        var node = checkGridSelected(car);
                        if (node) {
                            var id = '';
                            for (var i = 0; i < node.length; i++) {
                                if (node[i].get('Id') == 0) {
                                    car.store.remove(node[i]);
                                } else {
                                    id += node[i].get('Id') + ",";
                                }
                            }
                            id = id.substring(0, id.length - 1);
                            if (id && id != '' && id != null) {
                                Ext.Msg.confirm('提示', '确认要移除选中的数据吗？', function (btn) {
                                    if (btn == 'yes') {
                                        Ext.Msg.wait('正在移除数据，请稍候……', '移除数据');
                                        //var fIds = getIdFromGrid(node, 'Id');
                                        ajaxCalled(null, '../Service/PersonService.aspx?Action=DeleteCars', id, car, null);
                                    }

                                })
                            }
                        }
                    }
                }, '-', {
                    text: '保存',
                    iconCls: 'save',
                    id: 'SaveCarDetail',
                    handler: function () {
                        if (car.gridType == 1) {
                            car.onSaveCarClick(car, bp.BusinessPersonEditGrid, currtWind);
                        }
                        else if (car.gridType == 2) {
                            car.onSaveCarClick(car, hpap.HousePersonEditGrid, currtWind);
                        }
                    }
                }, '-', {
                    text: '查看',
                    iconCls: 'CheckDetails',
                    id: 'CheckDetails',
                    handler: function () { car.onCheckDetailsClick(); }
                }
                ]
        });
        car.onUpdataCarClick('<%=GetCreatePoliceCode() %>', car.Id,car.btnEnable);
        var CarRecord = new Ext.data.Record.create([
                     { name: 'Id', type: 'int' },
                     { name: 'Number', type: 'int' },
                     { name: 'CreateDate', type: 'string' },
                     { name: 'Enable', type: 'bool' }
                ]);
        function carCellRecoder() {
            var count = car.store.getCount();
            var p = new CarRecord({
                Id: 0,
                //PoliceSquadron: '',
                Number: '',
                Enable: '',
                CreateDate: ''

            })
            car.store.insert(count, p);
        }

    </script>
</head>
<body>
    <div id="car_div">
    </div>
</body>
</html>
